package org.kealinghornets.jchuah.buttons;

import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;


public class LEVEL2ACTIVITY extends MainActivity {

    public void checkVictory() {
        View topleft_android = findViewById(R.id.topleft_android);
        View topmiddle_android = findViewById(R.id.topmiddle_android);
        View topright_android = findViewById(R.id.topright_android);
        View bottomleft_android = findViewById(R.id.bottomleft_android);
        View bottommiddle_android = findViewById(R.id.bottommiddle_android);
        View bottomright_android = findViewById(R.id.bottomright_android);
        if (topleft_android.getVisibility() == View.INVISIBLE && topmiddle_android.getVisibility() == View.INVISIBLE && topright_android.getVisibility() == View.INVISIBLE && bottomleft_android.getVisibility() == View.INVISIBLE && bottommiddle_android.getVisibility() == View.INVISIBLE && bottomright_android.getVisibility() == View.INVISIBLE) {
            Toast.makeText(this,"You beat Level 2",Toast.LENGTH_LONG).show();

            startActivity(new Intent(this, LEVEL3ACTIVITY.class));
        }
    }

    public void ontopright_bottonPush(View view) {
        toggleVisibility(R.id.topmiddle_android);
        checkVictory();
    }

    public void ontopleft_buttonPush(View view) {
        toggleVisibility(R.id.bottomleft_android);
        checkVictory();
    }

    public void ontopmiddle_buttonPush(View view) {
        toggleVisibility(R.id.bottommiddle_android);
        checkVictory();
    }

    public void onbottomright_buttonPush(View view) {
        toggleVisibility(R.id.topleft_android);
        checkVictory();
    }

    public void onbottomleft_buttonPush(View view) {
        toggleVisibility(R.id.topright_android);
        checkVictory();
    }

    public void onbottommiddle_buttonPush(View view){
        toggleVisibility(R.id.bottomright_android);
        checkVictory();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_level2_activity);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_level2_activity, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}
